/***
 * 组合商品统计信息（售罄，下架数）
 */
import { Alert } from 'antd';
import { useEffect, useState } from 'react';
import { getStatic } from '../service';

export default ({ tableKey, countKey }) => {

	//顶部统计信息
	const [countData, setCountData] = useState({
		soldOut: 0,
		lowerShelf: 0,
	});

	useEffect(() => {
		queryCountData();
	}, [tableKey, countKey])

	//获取顶部统计信息
	const queryCountData = async () => {
		const { success, data } = await getStatic();
		if (success) {
			setCountData(data);
		}
	};

	return (
		<Alert
			style={{ margin: '8px 0 16px' }}
			message={
				<div className="common-color4">
					共<span className="common-color9"> {countData.lowerShelf} </span>
					个组合商品被下架，
					<span className="common-color9"> {countData.soldOut} </span>
					个组合商品已售罄
				</div>
			}
			type="info"
		/>
	)
}